<template>
  <div class="User">
    <el-menu
        mode="horizontal"
        background-color="#545c64"
        text-color="#fff">
      <el-menu-item @click="gouser()">返回 </el-menu-item>
      <el-menu-item @click="unlogin()"style="position: fixed;right: 19px;top: 8px">注销</el-menu-item>
    </el-menu>
    <br><br>
    <el-button type="primary" style="position: relative;right: 5px" @click="search()">
      <el-icon style="vertical-align: middle;">
        <search />
      </el-icon>
      <span style="position: relative;right: 5px"> 搜索 </span>
    </el-button>
    <el-input
        v-model="input"
        placeholder="输入查询课程号"
        style="width: 200px"
    />
    <el-button type="primary" style="position: relative;right: -900px" @click="add({nickname:inputname,id:inputid})">
      <span style="position: relative;right: 5px"> 添加 </span>
    </el-button>
    <el-input
        v-model="inputname"
        placeholder="输入查询姓名"
        style="width: 200px"
    /> <el-input
      v-model="inputid"
      placeholder="输入查询学号"
      style="width: 200px"
  />
    <br><br>
    <el-table :data="data" stripe border style="width: 100%">
      <el-table-column prop="nickname" label="教师姓名"></el-table-column>
      <el-table-column prop="id" label="教师ID"></el-table-column>
      <el-table-column label="操作">
        <el-button type="primary" style="position: relative;right: -15px" @click="revise(index)">
          <span style="position: relative;right: 2px"> 删除 </span>
        </el-button>
      </el-table-column>
    </el-table>
  </div>
</template>

<script>
export default {
  created() {
    axios.get('/member/findAllTeacher').then(res=>{
      console.log(res);
      this.data=res.data.data
    })
  },
  data(){
    return{
      inputid:'',
      inputname:'',
      inputsex:'',
      index:'',
      input:'',
      data:[{nickname:'li',id:'2'}],
    }
  },
  methods:{
    add(data){
      // this.$router.push('/register');
      this.data.splice(0,0,data)
    },
    revise(index){
      this.data.splice(index,1)
    },
    search(){
      axios.post('').then(res=>{
        console.log(res)
        this.data=res
      })
    },
    gouser() {
      this.$router.push('/user/');
    },
    unlogin(){
      axios.post('/user/logout').then(res=> {
        if(res.data.code===10000){
          this.$message.success(res.data.msg);
          this.$router.push('/login');
        }else{
          this.$message.error(res.data.msg);
        }
      })
    }

  }
}
</script>

<style scoped>

</style>